#!/bin/bash
if [ "$1" == "--help" ]; then
    echo usage: "$0" [--rebuild]
    echo Set USE_MSBUILD=1 or USE_XBUILD=1 to specify build engine
    echo xbuild is default
    exit 0
fi
XBUILD=xbuild
MONO=mono
if [ $(uname) == "Darwin" ]; then
	XBUILD=/Library/Frameworks/Mono.framework/Versions/Current/bin/xbuild
	MONO=/Library/Frameworks/Mono.framework/Versions/Current/bin/mono
fi

if [ ! -f "sspack/bin/Debug/sspack.exe" ] || [ "$1" == "--rebuild" ]; then
    cd sspack
    if [ "$USE_MSBUILD" == "1" ]; then
	msbuild /p:Configuration=Debug /p:Platform=AnyCPU
    elif [ "$USE_XBUILD" == "1" ]; then
	$XBUILD /p:Configuration=Debug /p:Platform=AnyCPU
    else
	$XBUILD /p:Configuration=Debug /p:Platform=AnyCPU
    fi    
    cd ..
fi
$MONO sspack/bin/Debug/sspack.exe /pow2 /sqr /image:../src/Editor/LibreLancer.ImUI/icons.png /map:../src/Editor/LibreLancer.ImUI/icons.txt *.png
